package com.test.lol;

import android.content.*;
import android.util.*;
import android.view.*;
import android.widget.*;
import java.util.*;


public class CommentArrayAdapter extends ArrayAdapter<CommentObject> {


	Context context;
	int resource;
	private LayoutInflater mInflater;
	

	public CommentArrayAdapter(Context context, int resource, List<CommentObject> objects) {
		super(context, resource, objects);
		this.resource = resource;
		mInflater = LayoutInflater.from(context);
			
	}

	
	public View getView(int position, View convertView, ViewGroup parent){
		
		LinearLayout commentView;
		CommentObject co = (CommentObject) getItem(position);
		
		Log.v(this.getClass().getName(), "Name: " + co.getName()+ " Comment " + co.getComment());
		
		if(convertView == null){
			commentView = new LinearLayout(getContext());
			String inflate = Context.LAYOUT_INFLATER_SERVICE;
			mInflater = (LayoutInflater) getContext().getSystemService(inflate);
			mInflater.inflate(resource, commentView, true);

		}else{
			commentView = (LinearLayout) convertView;
		}
		
		TextView nameTextView = (TextView) commentView.findViewById(R.id.name);
		TextView commentTextview = (TextView) commentView.findViewById(R.id.comment);	
		
		nameTextView.setText("Name: " + co.getName());
		commentTextview.setText("Comment: " + co.getComment());
		
		return commentView;	
	}	
}
